package de.lns.entities.ai;

import de.lns.entities.turrets.Bullet;
import de.lns.tick.UpdateThread;
/**
 * 
 * @author Frederick
 *
 */
public class HomingBulletai extends Bulletai {
	/**
	 * hypotenuseLength: the length of the distance between the bullet and the mob's position
	 * bullet: Bullet object
	 */
	private double hypotenuseLength;
	private Bullet bullet;
	
	/**
	 * 
	 * @param bullet: the bullet that's currently being moved
	 */
	public HomingBulletai(Bullet bullet) {
		this.bullet = bullet;
	}
	
	/**
	 * method to move the bullet
	 */
	public void move() {

		hypotenuseLength = Math.hypot(
				bullet.getTarget().getPosX() - bullet.getPosX(), bullet
						.getTarget().getPosY() - bullet.getPosY());
		bullet.setPosX(bullet.getPosX()
				+ ((bullet.getTarget().getPosX() - bullet.getPosX()) / (hypotenuseLength / bullet
						.getSpeed())) * UpdateThread.getDelta() / 1000);
		bullet.setPosY(bullet.getPosY()
				+ ((bullet.getTarget().getPosY() - bullet.getPosY()) / (hypotenuseLength / bullet
						.getSpeed())) * UpdateThread.getDelta() / 1000);
		

	}

}
